package flc.ast.adapter;

import android.widget.ImageView;

import androidx.annotation.NonNull;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import java.util.Random;

import flc.ast.R;
import stark.common.basic.adaptermutil.StkEmptyProvider;
import stark.common.basic.adaptermutil.StkProviderMultiAdapter;
import stark.common.bean.StkResBean;

public class TabAdapter extends StkProviderMultiAdapter<StkResBean> {

    public TabAdapter() {
        addItemProvider(new StkEmptyProvider<>(112));
        addItemProvider(new TabProvider());
    }

    private class TabProvider extends BaseItemProvider<StkResBean> {
        @Override
        public int getItemViewType() {
            return StkProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_tab;
        }

        @Override
        public void convert(@NonNull BaseViewHolder baseViewHolder, StkResBean bean) {
            Glide.with(baseViewHolder.itemView).load(bean.getThumbUrl()).into((ImageView) baseViewHolder.getView(R.id.ivTabItemImg));
            baseViewHolder.setText(R.id.tvTabItemTitle, bean.getName());
            baseViewHolder.setText(R.id.tvTabItemDesc, bean.getDesc());
            Random random=new Random();
            int number=random.nextInt(2000)+1000;
            baseViewHolder.setText(R.id.tvTabItemNum,getContext().getString(R.string.read_num,number));
        }
    }

}
